/**
 *  @file JSONTokenizer.h
 */
#ifndef _JSONTOKENIZER_H_
#define _JSONTOKENIZER_H_

#include "../../common/BaseObject.h"
#include "../../text/CFString.h"
#include "../../io/Reader.h"


namespace cppflib
{

namespace json
{

class JSONTokenizer : public BaseObject
{
public:
    typedef enum
    {
       JN_UNKNOWN,

       JN_READEREND,

       JN_OBJSTART,   ///< {
       JN_OBJEND,     ///< }
       JN_ARRAYSTART, ///< [
       JN_ARRAYEND,   ///< ]
       
       JN_STRING,
       JN_COLON,      ///< :
       JN_COMMA,      ///< ,
       JN_INT32,
       JN_INT64,
       JN_INT64OVERFLOW,
       JN_DOUBLE,
       JN_TRUE,       ///< true  (case sensitive)
       JN_FALSE,      ///< false (case sensitive)
       JN_NULL,       ///< null  (case sensitive)
 
       JN_SINGLELINE_COMMENT,   ///< C-style single line comment //
       JN_COMMENT_START,        ///< C-style comment start /*
       JN_COMMENT_END,          ///< C-style comment end   */

    } tokentype_t;

private:
    int lineNum;  ///< line number
    io::Reader *pReader; ///< input reader

private:
	JSONTokenizer(void);

public:
    explicit JSONTokenizer(io::Reader *pReader);
	virtual ~JSONTokenizer(void);

    void IncrementLineNumber();
    io::Reader *GetReader();  
    int GetLineNumber();
    
    tokentype_t GetToken(CFString &token);
};

} // end of namespace json

} // end of namespace cppflib

#endif
